﻿using Newtonsoft.Json;

namespace AutomationCommand
{
    public class ml_elmt_date : BasiCommand
    {
        [JsonProperty("by_type")]
        public string ByType { get; set; }

        [JsonProperty("by_content")]
        public string ByContent { get; set; }

        [JsonProperty("keyname")]
        public string Keyname { get; set; }

        [JsonProperty("sql")]
        public SqlOption Sql { get; set; }

        [JsonProperty("overtime")]
        public int Overtime { get; set; }

        public ml_elmt_date()
        {
            FunctionType = "ml_elmt_date";
            OtherName = "元素数据";
            ByType = "";
            ByContent = "";
            Keyname = "-1";
            Sql = new SqlOption
            {
                Tablename = "",
                Ck = "0",
                Cdt = new CdtOption
                {
                    K = "",
                    R = "",
                    V = ""
                }
            };
            Overtime = 15000;
            SuccessJump = -1;
            FailureJump = -1;
        }

        public bool Execute()
        {
            // 在这里编写执行命令的逻辑
            // 返回执行结果
            return true; // 假设此处始终成功
        }

        public class SqlOption
        {
            [JsonProperty("tablename")]
            public string Tablename { get; set; }

            [JsonProperty("ck")]
            public string Ck { get; set; }

            [JsonProperty("cdt")]
            public CdtOption Cdt { get; set; }
        }

        public class CdtOption
        {
            [JsonProperty("k")]
            public string K { get; set; }

            [JsonProperty("r")]
            public string R { get; set; }

            [JsonProperty("v")]
            public string V { get; set; }
        }
    }
}
